import 'package:flutter/material.dart';
import 'package:transparent_image/transparent_image.dart';
import '../../routers/application.dart';

class OrdersOverview extends StatefulWidget {
  @override
  OrdersOverviewState createState() => new OrdersOverviewState();
}

class OrdersOverviewState extends State<OrdersOverview> {
  List<Map<String, Object>> _ordersList = new List();
  @override
  void initState() {
    super.initState();
    _ordersList
      ..add({"icon": Icon(Icons.inbox), "client": "香港兴通玩具有限公司", "product": "兴通3型儿童学步车", "quantity": 1000, "progress": "523",})
      ..add({"icon": Icon(Icons.inbox), "client": "上海未来酒店", "product": "酒店方形登", "quantity": 500, "progress": "250",})
      ..add({"icon": Icon(Icons.inbox), "client": "上海未来酒店", "product": "酒店方形登", "quantity": 500, "progress": "250",})
      ..add({"icon": Icon(Icons.inbox), "client": "上海未来酒店", "product": "酒店方形登", "quantity": 500, "progress": "250",})
      ..add({"icon": Icon(Icons.inbox), "client": "上海未来酒店", "product": "酒店方形登", "quantity": 500, "progress": "250",})
      ..add({"icon": Icon(Icons.inbox), "client": "上海未来酒店", "product": "酒店方形登", "quantity": 500, "progress": "250",})
      ..add({"icon": Icon(Icons.inbox), "client": "香港兴通玩具有限公司", "product": "兴通3型儿童学步车", "quantity": 1000, "progress": "523",})
      ..add({"icon": Icon(Icons.inbox), "client": "上海未来酒店", "product": "酒店方形登", "quantity": 500, "progress": "250",})
      ..add({"icon": Icon(Icons.inbox), "client": "上海未来酒店", "product": "酒店方形登", "quantity": 500, "progress": "250",})
      ..add({"icon": Icon(Icons.inbox), "client": "香港兴通玩具有限公司", "product": "兴通3型儿童学步车", "quantity": 1000, "progress": "523",})
      ..add({"icon": Icon(Icons.inbox), "client": "上海未来酒店", "product": "酒店方形登", "quantity": 500, "progress": "250",})
      ..add({"icon": Icon(Icons.inbox), "client": "上海未来酒店", "product": "酒店方形登", "quantity": 500, "progress": "250",})
      ..add({"icon": Icon(Icons.inbox), "client": "香港兴通玩具有限公司", "product": "兴通3型儿童学步车", "quantity": 1000, "progress": "523",})
      ..add({"icon": Icon(Icons.inbox), "client": "上海未来酒店", "product": "酒店方形登", "quantity": 500, "progress": "250",})
      ..add({"icon": Icon(Icons.inbox), "client": "上海未来酒店", "product": "酒店方形登", "quantity": 500, "progress": "250",})
      ..add({"icon": Icon(Icons.inbox), "client": "香港兴通玩具有限公司", "product": "兴通3型儿童学步车", "quantity": 1000, "progress": "523",})
      ..add({"icon": Icon(Icons.inbox), "client": "上海未来酒店", "product": "酒店方形登", "quantity": 500, "progress": "250",})
      ..add({"icon": Icon(Icons.inbox), "client": "上海未来酒店", "product": "酒店方形登", "quantity": 500, "progress": "250",})
      ..add({"icon": Icon(Icons.inbox), "client": "香港兴通玩具有限公司", "product": "兴通3型儿童学步车", "quantity": 1000, "progress": "523",})
      ..add({"icon": Icon(Icons.inbox), "client": "上海未来酒店", "product": "酒店方形登", "quantity": 500, "progress": "250",})
      ..add({"icon": Icon(Icons.inbox), "client": "上海未来酒店", "product": "酒店方形登", "quantity": 500, "progress": "250",})
      ..add({"icon": Icon(Icons.inbox), "client": "香港兴通玩具有限公司", "product": "兴通3型儿童学步车", "quantity": 1000, "progress": "523",})
      ..add({"icon": Icon(Icons.inbox), "client": "上海未来酒店", "product": "酒店方形登", "quantity": 500, "progress": "250",})
      ..add({"icon": Icon(Icons.inbox), "client": "上海未来酒店", "product": "酒店方形登", "quantity": 500, "progress": "250",})
    ;
  }

  @override
  Widget build(BuildContext context) {
    //super.build(context);
    return Scaffold(
        // appBar: renderAppBar(context, widget, _currentIndex),
        body: CustomScrollView(
      shrinkWrap: true,
      slivers: <Widget>[
        SliverAppBar(
          flexibleSpace: FlexibleSpaceBar(
              //可以展开区域，通常是一个FlexibleSpaceBar
              centerTitle: true,
              title: Text("生产进度"),
              background: Image.network(
                "https://iiot.jp/wp-content/uploads/2019/01/dc4775226e5370fa43eeef2d0b421186.jpg",
                fit: BoxFit.cover,
              )),
          primary: true, //是否预留高度
          forceElevated: true,
          automaticallyImplyLeading: true,
          snap: false, //与floating结合使用
          expandedHeight: 100.0, //展开高度
          floating: false, //是否随着滑动隐藏标题
          pinned: true, //是否固定在顶部
          backgroundColor: Colors.lightGreen,
        ),
        SliverPadding(
          padding: const EdgeInsets.all(0.0),
          sliver: SliverList(
            delegate: SliverChildBuilderDelegate(
              (BuildContext context, int index) {
                return ListTile(
                  leading: _ordersList[index]["icon"],
                  title: Text(_ordersList[index]["client"]),
                  subtitle: Text(_ordersList[index]["product"]),
                  trailing: Text(
                      "${_ordersList[index]["progress"]}/${_ordersList[index]["quantity"]}"),
                );
              },
              childCount: _ordersList.length,
            ),
          ),
        ),
        SliverToBoxAdapter(
            child: Container(
          width: 100,
          height: 300,
        )),
      ],
    ));
  }

  void testPress(BuildContext context, int index) {
    final snackBar = SnackBar(
      content: Text('Yay! A SnackBar! $index'),
      action: SnackBarAction(
        label: 'Undo',
        onPressed: () {
          // Some code to undo the change.
        },
      ),
    );

    // Find the Scaffold in the widget tree and use
    // it to show a SnackBar.
    Scaffold.of(context).showSnackBar(snackBar);
  }
}
